package inabit.inabitcompiler.productions.variable.types;

import inabit.compiler.parser.grammar.NonTerminal;
import inabit.compiler.parser.grammar.Production;
import inabit.compiler.parser.grammar.Symbol;
import inabit.compiler.parser.grammar.Terminal;
import inabit.inabitcompiler.lexical.InabitTokenClass;
import inabit.inabitcompiler.parser.InabitSemanticAction;

/**T -> enumerated(P)*/
/**@author Rafael Rocha*/
public class T_Rule3 extends Production{
	private NonTerminal P;
	
	public T_Rule3() {
		super("T");
	}

	@Override
	protected Symbol[] production(final NonTerminal nonTerminal) {
		P = new NonTerminal("P");
		Symbol[] symbols = {
				new Terminal(InabitTokenClass.ENUMERATION),
				new Terminal(InabitTokenClass.OPEN_PARENTHESIS),
				P,
				new Terminal(InabitTokenClass.CLOSE_PARENTHESIS),
				new InabitSemanticAction(nonTerminal) {
					
					@Override
					public void execute() throws Exception {
						nonTerminal.code = "enum:"+P.code;
					}
				}
		};
		return symbols;
	}
}
